#include<iostream>
#include<cstring>
using namespace std;

char num[240];
bool del[240];

int main() {
    int count;
    while(scanf("%s", &num) != EOF) {
        string str = num;
        cin >> count;
        memset(del, false, sizeof(del));

//      特例处理
        if (count >= strlen(num)) {
            cout << -1 << endl;
            break;
        } else if (count == strlen(num)-1) {
            cout << "" <<endl;
            break;
        }

//      删数核心
        while(count--) {
            for (int left=0, right=1; left<strlen(num); left++, right++) {
            	if (del[left]) {
            		right = left + 1;
				} else if (del[right]) {
                    left--;
                } else if (right >= strlen(num) || num[left] > num[right]) {
                    del[left] = true;
                    num[left] = '0';
                    break;
                }
            }
        }

//      输出
        bool flag = false;
        for(int i=0; i<strlen(num); i++) {
            if(!flag && str[i] == '0')
                continue;
            if (del[i])
                continue;
            else {
                cout << str[i];
                flag = true;
            }
        }
        cout << endl;

        memset(num, 0, sizeof(num));
    }
    return 0;
}